import api from './index'
import { axios } from '@/utils/request'

export function login (parameter) {
  return axios({
    url: '/system/auth/login',
    method: 'post',
    data: parameter
  })
}

export function getSmsCaptcha (parameter) {
  return axios({
    url: api.SendSms,
    method: 'post',
    data: parameter
  })
}

export function getInfo () {
  return axios({
    url: '/system/auth/info',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function getCurrentUserNav (token) {
  return axios({
    url: '/system/auth/nav',
    method: 'get'
  })
}

export function getCurrentUserBtns () {
  return axios({
    url: '/system/auth/btns',
    method: 'get'
  })
}

export function getMessageCounts () {
  return axios({
    url: '/system/auth/messageCounts',
    method: 'get'
  })
}

export function getMessageInfoList () {
  return axios({
    url: '/system/auth/getMessageInfoList',
    method: 'get'
  })
}

export function logout () {
  return axios({
    url: '/system/auth/logout',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 获取后端路由信息的 axios API
 * @returns {Promise}
 */
export const getRouterByUser = () => {
  return axios({
    url: '/user/dynamic-menu',
    method: 'get'
    /* headers: {
      'Access-Token': 'xxx'
    }
    */
  })
}
